import request from '@/utils/request'
import { QueryType, SortPage, type Response } from './common.type'

export type RegistryType = {
	username: string

	password: string

	pwdRepeat: string

	gender: string

	age: number

	education: string

	receive: string
	
	career: string

	city: string

	hobby: string

	phoneNumber: string

	email: string

	remark: string

	// avatarObj: {
	// 	name: string
	// 	url: string
	// }
	avatarObj: string

	// fileList: Array<{
	// 	name: string
	// 	url: string
	// }>

	fileList: string
}

export type QueryUserType = {
	age?: number
	city?: string[]
	education?: string
	gender?: string
	receive?: string
	username?: string
}

export interface RowType extends Omit<RegistryType, 'password' | 'pwdRepeat'> {
	id: string
	createTime: string
	modifyTime: string
}

// 注册
export function registry(data: RegistryType): Promise<Response> {
  return request({
    url: '/user/registry',
    method: 'POST',
    data
  })
}

// 获取列表
export function getUserList<T>(data: QueryType<T>): Promise<Response<SortPage<RowType>>>{
  return request({
    url: '/user/list',
    method: 'POST',
    data
  })
}